package com.laikan.library.viewop;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

/**
 *
 * view 动态设置
 * Created by wx on 16/8/22.
 */
public class ViewOperation {

    /**
     * 父布局为RelativeLayout 动态设置view的位置 起点 x y (0,0)
     * @param waitView  需要操作的view
     * @param left     距左
     * @param top      距上
     * @param right    距右
     * @param bottom   距下
     */
    public static void setRelaViewMarginDistance(View waitView, int left, int top, int right, int bottom){

        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams)waitView.getLayoutParams();
        lp.setMargins(left,top,right,bottom);
        waitView.setLayoutParams(lp);
    }

    /**
     * 父布局为RelativeLayout 动态设置view的位置 起点 x y (0,0)
     * @param waitView  需要操作的view

     */
    public static void setRelaViewHeight(View waitView,int height){

        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams)waitView.getLayoutParams();
        lp.height = height;
        waitView.setLayoutParams(lp);
    }

    /**
     * 父布局为RelativeLayout 动态设置view的位置 起点 x y (0,0)
     * @param waitView  需要操作的view
     * @param left     距左
     * @param top      距上
     * @param right    距右
     * @param bottom   距下
     */
    public static void setLinViewMarginDistance(View waitView, int left, int top, int right, int bottom,int height){

        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)waitView.getLayoutParams();
        lp.height = height;
//        lp.setMargins(left,top,right,bottom);
        waitView.setLayoutParams(lp);
    }
}
